<template>
  <div class="home">
    <el-card style="margin: 10px">
      <el-table
        :data="areaList"
        style="width: 1500px"
        v-loading="loading"
        @selection-change="selectIcon"
        scrollbar-always-on
      >
        <el-table-column prop="areaName" label="名称"></el-table-column>
        <el-table-column prop="description" label="点位描述"></el-table-column>
        <el-table-column prop="longitude" label="经度"></el-table-column>
        <el-table-column prop="latitude" label="纬度"></el-table-column>
        <el-table-column label="操作" width="300" fixed="right">
          <template #default="scope">
            <div class="button-container">
              <el-button
                type="success"
                size="mini"
                @click="handleSwichMap(scope.row)"
                >查看地图</el-button
              >
              <el-button
                type="success"
                size="mini"
                @click="handleEditArea(scope.row)"
                >编辑</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
    
<script setup>
import { onMounted, reactive, toRefs } from "vue";
import Icon from "@/components/Icon.vue";
import Map from "@/components/Map.vue";
import http from "@/utils/http";
import { useRouter } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import { Search, Plus, Location } from "@element-plus/icons-vue";
const router = useRouter();

// 组件列表
const components = { Icon, Map };

const Data = reactive({
  areaList: [],
});
const { areaList, queryData, total } = toRefs(Data);
onMounted(() => {
  init();
});
const init = () => {
  http.get("/area/ua/listAreas", {}).then((res) => {
    Data.areaList = res.data;
  });
};
const handleUpdateClick = (item) => {
  console.log(item);
  router.push({
    path: "/home/editArea",
    query: { AreaId: item.id },
  });
};
const handleSwichMap = (e) => {
  router.push({
    path: "/home/pointManagement",
    query: { areaId: e.id },
  });
};
const handleEditArea = (e) => {
  router.push({
    path: "/home/editArea",
    query: { areaId: e.id },
  });
};
</script>

<style>
.el-table {
  .el-table__body-wrapper {
    overflow-x: scroll !important;
  }
}
.custom-form {
  display: flex;
  flex-wrap: wrap;
}
.form-item {
  width: calc(40% - 50px); /* Adjust the width and margin as needed */
  margin-right: 20px;
  margin-bottom: 20px;
}
.button-container {
  display: flex;
  gap: 5px; /* Adjust gap as needed */
  margin: 2px;
}
</style>